package demo;

import demo.compoment.BeanCompoment;
import demo.compoment.UserCompoment;
import demo.controller.UserController;
import demo.controller.UserController2;
import demo.enity.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        /* ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");*/
        //不用这种方式进行获取上下文对象了，因为没销毁方法，既然我们想看生命周期，得有销毁方法。
        /* UserCompoment userCompoment = context.getBean(UserCompoment.class);*/
/*        UserController userController = context.getBean(UserController.class);
        UserController2 userController2 = context.getBean(UserController2.class);
    *//*    userCompoment.test();*//*
        userController.printUser();
        userController2.printUser();*/
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        BeanCompoment beanCompoment = context.getBean("beanCompoment", BeanCompoment.class);
        beanCompoment.sayHi();
        context.destroy();
    }
}
